#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, m, anst = 1ll << 60;
string s[1000006], ys[1000006], ans[1000006];
int vis[23][23];
vector<pair<int, int>> fps;
const int d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

void dfs(int i, int j, int t1) {
	if (i == n + 1) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				if (ys[i][j] == '#') {
					if (!vis[i][j]) {
						return;
					}
				}
			}
		}
		if (t1 < anst) {
			for (int k = 1; k <= m; ++k) ans[k] = s[k];
			anst = t1;
			return;
		}
		return;
	}
	if (j == m + 1) return dfs(i + 1, 1, t1);
	if (s[i][j] == '.') return dfs(i, j + 1, t1);
	if (s[i][j] == '#') {
		s[i][j] = '1';
		for (int k = 0; k < 4; ++k) {
			int nx = d[k][0] + i, ny = d[k][1] + j;
			vis[nx][ny]++;
		}
		vis[i][j]++;
		dfs(i, j + 1, t1 + 1);
		vis[i][j]--;
		for (int k = 0; k < 4; ++k) {
			int nx = d[k][0] + i, ny = d[k][1] + j;
			vis[nx][ny]--;
		}
		s[i][j] = '0';
		dfs(i, j + 1, t1);
		s[i][j] ='#';
	}
}

signed main() {
	freopen("indian.in", "r", stdin); freopen("indian.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		s[i] = " " + s[i];
		ys[i] = s[i];
	}
	if (n * m <= 20) {
		dfs(1, 1, 0);
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				cout << ans[i][j];
			}
			cout << "\n";
		}
	} else {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				if (s[i][j] == '#') s[i][j] = '1';
				cout << s[i][j];
			}
			cout << "\n";
		}
	}
	return 0;
}
